package com.generator.statics.customerSalesStatics.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.generator.statics.customerSalesStatics.pojo.CustomCountCondition;
import com.generator.statics.customerSalesStatics.pojo.CustomerCount;
import com.generator.statics.customerSalesStatics.pojo.OrderOfProduct;
import com.generator.statics.customerSalesStatics.pojo.ProvinceCity;
import com.generator.statics.customerSalesStatics.service.CustomerCountService;
import com.generator.util.PageModel02;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 88168
 * @since 2022-10-01
 */
@RestController
public class CustomCountController {

    @Autowired
    private CustomerCountService customerCountService;


    /**
     * 客户销量统计1,2
     */
    @GetMapping("/customCount")
    private Page<CustomerCount> selectCount(CustomerCount customerCount,Page<CustomerCount> page) {
        Page<CustomerCount> list = customerCountService.selectCustomCount(customerCount,page);
        List<CustomerCount> records = list.getRecords();
        return list;
    }
    /**
     * 客户销量统计1,2
     */
    @GetMapping("/customCount02")
    private PageModel02<CustomerCount>  selectCount02(CustomerCount customerCount, PageModel02<CustomerCount> pageModel) {
        PageModel02<CustomerCount> customerCountPageModel02 = customerCountService.selectCustomCount02(customerCount, pageModel);
        return customerCountPageModel02;
    }
    /**
     * 订购单详情
     */
    @GetMapping("/orderingInformation/{orderId}")
    private  List<CustomerCount> selectOrderingInformation(@PathVariable String orderId) {
        List<CustomerCount> customerCount = customerCountService.selectOneCustom(orderId);
        return customerCount;
    }
    /**
     * 订购单--商品
     */
    @GetMapping("/selectProductsByOrderId/{orderId}")
    private List<OrderOfProduct> selectProductsByOrderId(@PathVariable String orderId) {
        List<OrderOfProduct> customerCount = customerCountService.selectProductsByOrderId(orderId);
        return customerCount;
    }
    /**
     * 多条件查询
     */
    @RequestMapping(value ="/customCountByCondition" ,produces = "application/json;charset=UTF-8")
    private Page<CustomerCount> selectCustomCountByCondition( CustomCountCondition customCountCondition) {
        Page<CustomerCount> list = customerCountService.selectCustomCountByCondition(customCountCondition);
        return list;
    }
    /**
     *
     * @param pName
     * @return 返回省对应的城市
     */
    @GetMapping("/cityByProvince1/{pName}")
    public List<ProvinceCity> cityByProvince(@PathVariable String pName){
        List<ProvinceCity> provinceCities = customerCountService.cityByProvince(pName);
        return provinceCities;
    }
}

